package DPT_167;

public class Solution {
	public int[] twoSum(int[] numbers, int target) {
		int n = numbers.length;
		for (int i = 0; i < n; i++) {
			for (int j = i + 1; j < n; j++) {
				if (numbers[i] + numbers[j] == target) {
					return new int[] { i + 1, j + 1 };
				}
			}
		}
		return null;
	}

	public int[] twoSum_DPT(int[] numbers, int target) {
		int low = 0, high = numbers.length - 1;
		while (low < high) {
			int sum = numbers[low] + numbers[high];
			if (sum == target) {
				return new int[] { low + 1, high + 1 };
			} else if (sum < target) {
				low++;
			}else {
				high--;
			}
		}
		return null;

	}
}
